import router from 'umi/router';

import React from 'react';
import { connect } from 'dva';
import Link from 'umi/link'
import { Table, Button } from 'antd';

import DescriptionList from '@/components/DescriptionList';
//const { Description } = DescriptionList;


const linePath = '/AccountMove/AccountMove';
const formPath = '/AccountMove/AccountMoveForm';


@connect(({ accountMove }) => ({ accountMove }))
class List extends React.Component {
  state = {
  }

  treeview = [
      {
        title: '',
        dataIndex: '_',
        render: (_, { id }) => {
          return <Link to={`${linePath}?id=${id}`}>查看</Link>;
        },
      },
      { title: '账簿', dataIndex: 'journal_id.name', },
      { title: '凭证号', dataIndex: 'name_cn', },
      { title: '名称', dataIndex: 'name', },
      { title: '日期', dataIndex: 'date', },
      { title: '金额', dataIndex: 'amount', },
      { title: '摘要', dataIndex: 'ref', },
      { title: '附件数', dataIndex: 'attachment_count', },
      { title: '状态', dataIndex: 'state', },
  ]

  async componentDidMount() {
    const { dispatch } = this.props;
    dispatch({
      type: 'accountMove/search',
      payload: {domain:[], },

    });
  }


  goto_createForm() {
      router.push(formPath);
  }


  render() {
    const { accountMove: { recordsList } } = this.props;
    //console.log('page error: ',error)

    return (
      <div>
        <DescriptionList size="large" title='说明' style={{ marginBottom: 32 }}>
          <div>收/付款单/内部转款单，生成的凭证，会计只能查询，不能编辑</div>
          <div>会计在这里 制作转账凭证</div>
          <div>费用报销/资产折旧/工资/发票 等由其他模型自动生成的转账凭证，在这里只能查询</div>
          <div>税务处理，库存处理生成的凭证，在这里只能查询</div>

        </DescriptionList>

        <Button onClick={()=>this.goto_createForm()}>新建</Button>
        <Table columns={this.treeview} dataSource={recordsList} rowKey="id" />


      </div>
    );
  }
}

export default List;





